package com.mdjnu.mapper;

import com.mdjnu.pojo.Comment;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
//告诉SpringBoot这是一个Mapper类
public interface CommentMapper {
    //添加评论
    @Insert("insert into Comments(video_id,user_id,content,like_count,dislike_count,comment_time,status) values(#{videoId},#{userId},#{content},#{likeCount},#{dislikeCount},#{commentTime},#{status})")
    int addComment(Comment comment);
    @Select("select * from Comments where video_id= #{videoId} limit #{starter},#{pageSize}")
    List<Comment> findByVideoId(int videoId,int starter,int pageSize);
    @Update("update Comments set like_count=like_count+1 where comment_id= #{commentId}")
    int addLikeCount(int commentId);

}
